package com.hong610.quartz.core;

import org.quartz.*;
import org.quartz.impl.matchers.GroupMatcher;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * Quartz管理类
 * Created by Hong on 2017/2/7.
 */
public class QuartzManager extends QuartzCore {

    /**单例对象**/
    private static QuartzManager quzrtzManager = null;

    /**
     * 实例化
     */
    public static QuartzManager instance(){
        if(quzrtzManager == null)
            quzrtzManager = new QuartzManager();
        return quzrtzManager;
    }

    /**
     * 获取全部TriggerKey
     * @throws SchedulerException
     */
    public List<TriggerKey> getAllTriggerKey() throws SchedulerException {
        List<TriggerKey> list = new ArrayList<TriggerKey>();
        //获取调度器中所有的触发器组
        Set<TriggerKey> set = getScheduler().getTriggerKeys(GroupMatcher.anyTriggerGroup());
        list.addAll(set);
        return list;
    }
}
